package com.edu.exam.entity.examination.paper.technical;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import com.edu.exam.enums.examination.paper.ExamIdRecognitionMethod;
import com.edu.exam.enums.examination.paper.ValidationStatus;

import jakarta.persistence.*;
import java.time.LocalDateTime;

/**
 * 考号识别结果实体类
 *
 * 根据E-04-01设备适配子模块数据库设计实现
 * 存储考号识别的详细结果数据。
 *
 * @author System
 * @version 1.0.0
 */

@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class ExamIdRecognitionResult {

    /**
     * 结果ID，主键
     */
    @Id
    @Column(name = "result_id", length = 64)
    private String resultId;

    /**
     * 识别结果ID（外键）
     */
    @Column(name = "recognition_result_id", length = 64, nullable = false)
    private String recognitionResultId;

    /**
     * 考试ID
     */
    @Column(name = "exam_id", length = 64, nullable = false)
    private String examId;

    /**
     * 学生ID
     */
    @Column(name = "student_id", length = 64)
    private String studentId;

    /**
     * 班级ID
     */
    @Column(name = "class_id", length = 64)
    private String classId;

    /**
     * 识别出的考号
     */
    @Column(name = "recognized_exam_id", length = 128)
    private String recognizedExamId;

    /**
     * 识别方法
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "recognition_method", length = 32, nullable = false)
    private ExamIdRecognitionMethod recognitionMethod;

    /**
     * 置信度分数
     */
    @Column(name = "confidence_score", precision = 5, scale = 2)
    private Double confidenceScore;

    /**
     * 验证状态
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "validation_status", length = 32, nullable = false)
    private ValidationStatus validationStatus;

    /**
     * 是否人工验证
     */
    @Column(name = "manual_verification")
    private Boolean manualVerification;

    /**
     * 人工输入的考号
     */
    @Column(name = "manual_input", length = 128)
    private String manualInput;

    /**
     * 识别耗时（毫秒）
     */
    @Column(name = "recognition_time")
    private Long recognitionTime;

    // ================================
    // 审计字段
    // ================================

    @CreationTimestamp
    @Column(name = "created_time", nullable = false, updatable = false)
    private LocalDateTime createdTime;

    @UpdateTimestamp
    @Column(name = "updated_time")
    private LocalDateTime updatedTime;

    @Version
    @Column(name = "version")
    private Integer version = 0;

    @Column(name = "is_deleted")
    private Boolean isDeleted = false;
}